<template>
  <Header></Header>
  <div class="main ">
    <div class="body">
      <div class="content-left">
        <div class="allSpecial">
          <div class="iconTitle">
            <img src="/src/assets/icons/shopping_type.png" alt="" class="allSpecialIcon">
            <div class="title">Все колонки</div>
          </div>
          <img src="/src/assets/icons/close.png" alt="" class="iconOff">
        </div>
        <div class="mainNav">
          <div class="mainItem" :class="index === state.mainIndex ? 'mainItem_action':''" v-for="(item,index) of state.mainNavList"
               :key="index" @click="mainNavItemFUn(item.category_id,index)">
            <div class="itemIcon">
              <img :src="xxImg" alt="">
            </div>
            <div class="itemTitle" :class="index === state.mainIndex ? 'itemTitle_action':''">{{ item.translated_name }}</div>
          </div>
        </div>
      </div>
      <div class="content-right">
        <div class="rightTitle">
          <div class="titleIconBox">
            <img src="../../assets/image/xx.svg" alt="">
          </div>
          <div class="title">Мужская одежда</div>
        </div>
        <div class="rightContent">
          <div class="rightContent_left">
            <div :class="index === state.rightAcIndex ? 'leftTitle_action':'leftTitle'" v-for="(item,index) of state.rightContentList" :key="index"
                 @click="threeLevelFun(item,index)">{{ item.translated_name }}
            </div>
          </div>
          <div class="rightContent_right">
            <div class="typeGoodList">
              <div class="typeGoodItem" v-for="(item,index) of state.threeLevelList"
                   :style="{'margin-right': (index+1) % 5 == 0 ? '0' : '12px'}">
                <div class="typeGoodItem_img">
                  <img class="goodsImg" src="/src/assets/image/goodscs.png" alt="">
                </div>
                <div class="title multi-line-omit">{{ item.translated_name }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" name="Home" setup>
import Header from '../../components/Header/Header.vue'
import xxImg from '../../assets/image/xx.svg'
import {ref, reactive, onMounted} from "vue";
import {getCategoryList} from "@/api/api.ts";

const state = reactive({
  mainIndex:0,
  rightAcIndex:0,
  mainNavList: [],
  rightContentList: [],
  threeLevelList:[]
})
const getCategoryListFun = () => {
  getCategoryList({level: 1}).then((res: any) => {
    if (res.errCode === 0) {
      state.mainNavList = res.returnData
      mainNavItemFUn(state.mainNavList[0].category_id,0)
    }
  })
}
const mainNavItemFUn = (id: number,index:any) => {
  state.mainIndex = index
  // state.rightAcIndex = 0
  getCategoryList({topId: id}).then((res: any) => {
    if (res.errCode === 0) {
      state.rightContentList = res.returnData[0].children
      state.threeLevelList = state.rightContentList[0].children
    }
  })
}
const threeLevelFun = (item: any,index:number) => {
  state.rightAcIndex = index
  state.threeLevelList = item.children
}
onMounted(() => {
  getCategoryListFun()
})
</script>

<style lang="less" scoped>
::-webkit-scrollbar {
  display: none;
}
.multi-line-omit {
  word-break: break-all; // 允许单词内自动换行，如果一个单词很长的话
  text-overflow: ellipsis; // 溢出用省略号显示
  overflow: hidden; // 超出的文本隐藏
  display: -webkit-box; // 作为弹性伸缩盒子模型显示
  -webkit-line-clamp: 1; // 显示的行
  -webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上到下垂直排列
}
.main {
  background: #F6F6F6;
  padding-top: 16px;

  .body {
    display: flex;
    justify-content: center;

    .content-left {
      width: 220px;
      //height: 854px;
      //max-height: 854px;
      //overflow-y: auto;
      background: #FFFFFF;
      border-radius: 16px 16px 16px 16px;
      margin-right: 16px;
      box-sizing: border-box;
      padding: 20px 10px;
      align-self: flex-start;

      .allSpecial {
        cursor: pointer;
        width: 200px;
        height: 56px;
        background: #FFFFFF;
        border-radius: 8px 8px 8px 8px;
        border: 1px solid #CCCCCC;
        display: flex;
        align-content: center;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        padding: 0 10px;
        margin-bottom: 20px;

        .iconTitle {
          display: flex;
          align-content: center;
          align-items: center;

          .allSpecialIcon {
            width: 36px;
            height: 36px;
            margin-right: 8px;
          }

          .title {
            font-family: PingFang SC, PingFang SC;
            font-weight: bold;
            font-size: 14px;
            color: #333333;
            line-height: 14px;
            text-align: left;
            font-style: normal;
            text-transform: none;
          }
        }

        .iconOff {
          width: 16px;
          height: 16px;
        }
      }

      .mainNav {
        .mainItem_action {
          color: #FFFFFF !important;
          background-color: #0070E9;
        }

        .itemTitle_action {
          color: #FFFFFF !important;
        }

        .mainItem {
          display: flex;
          align-items: center;
          box-sizing: border-box;
          padding: 7px 10px;
          margin-bottom: 12px;
          width: 100%;
          cursor: pointer;
          border-radius: 8px;

          .itemTitle {
            margin-left: 10px;
            font-family: PingFang SC, PingFang SC;
            font-weight: bold;
            font-size: 12px;
            color: #333333;
            line-height: 12px;
            text-align: left;
            font-style: normal;
            text-transform: none;
          }

          .itemIcon {
            width: 30px;
            height: 30px;
            background-color: #F6F7FB;
            border-radius: 34px;
            display: flex;
            align-items: center;
            justify-content: center;

            img {
              width: 24px;
              height: 24px;
            }
          }
        }
      }

    }

    .content-right {
      width: 1164px;
      max-height: 1988px;
      background: #FFFFFF;
      border-radius: 16px 16px 16px 16px;
      box-sizing: border-box;
      padding: 20px;

      .rightTitle {
        width: 100%;
        max-height: 1908px;
        overflow: auto;
        display: flex;
        align-items: center;
        padding-bottom: 20px;
        border-bottom: 1px solid #EEEEEE;

        .titleIconBox {
          width: 24px;
          height: 24px;
          background-color: #0070E9;
          border-radius: 24px;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-right: 10px;

          img {
            width: 20px;
            height: 20px;
          }
        }

        .title {
          font-family: Segoe UI, Segoe UI;
          font-weight: bold;
          font-size: 24px;
          color: #333333;
          line-height: 24px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }

      .rightContent {
        //height: 100%;
        display: flex;
        max-height: 1908px;
        overflow: auto;
        .rightContent_left {
          width: 260px;
          align-self: flex-start;
          border-right: 1px solid #EEEEEE;
          box-sizing: border-box;
          padding-top: 15px;
          padding-right: 20px;

          .leftTitle {
            font-family: Segoe UI, Segoe UI;
            font-weight: 600;
            font-size: 14px;
            color: #999999;
            line-height: 14px;
            text-align: left;
            font-style: normal;
            text-transform: none;
            padding: 15px 0;
            cursor: pointer;
          }
          .leftTitle_action{
            font-family: Segoe UI, Segoe UI;
            font-weight: 600;
            font-size: 14px;
            color: #0070E9;
            line-height: 14px;
            text-align: left;
            font-style: normal;
            text-transform: none;
            padding: 15px 0;
            cursor: pointer;
          }
        }

        .rightContent_right {
          box-sizing: border-box;
          padding: 20px;
          flex: 1;
          max-height: 1908px;
          overflow: auto;

          .typeGoodList {
            display: flex;
            flex-wrap: wrap;

            .typeGoodItem {
              margin-bottom: 20px;
              cursor: pointer;

              .typeGoodItem_img {
                width: 155px;
                height: 155px;
                overflow: hidden;
                border-radius: 10px;

                img {
                  width: 100%;
                }
              }

              .title {
                font-family: Segoe UI, Segoe UI;
                font-weight: 600;
                font-size: 16px;
                color: #333333;
                line-height: 16px;
                text-align: center;
                font-style: normal;
                text-transform: none;
                margin-top: 16px;
                width: 144px;
              }
            }
          }
        }
      }
    }
  }

}
</style>
